//车辆详情
$(".car-info").click(function(){
    $(".myshowbox").show();
});
$(".btn_close").click(function(){
    $(".myshowbox").hide();
});

// 优惠活动
$(".ck-discount-code").click(function(){
    $(".discount-box").show();
    $(".corperate-box").hide();
});
$(".ck-ehi-act").click(function(){
    $(".discount-box").hide();
    $(".corperate-box").show();
});
$("#999").click(function(){
    $(".discount-box").hide();
    $(".corperate-box").hide();
});

var yhName = null;
var yhFree = 0;

//选中优惠卷
$(".discountcode-intro").click(function(){
    if ($(this).hasClass("discountcode-usable")) {
        $(this).addClass("discountcode-select").removeClass("discountcode-usable").children(".discountcode-title").addClass("discountcode-icons");
        $(this).parent().siblings().children(".discountcode-select").addClass("discountcode-usable").removeClass("discountcode-select").children(".discountcode-title")
            .removeClass("discountcode-icons");
    }

    //优惠减免

    var yhCheck = document.querySelector(".discountcode-select");
    // console.log(yhCheck)
    yhName = yhCheck.getAttribute("title");
    console.log("yhName: "+yhName)
    yhFree = document.querySelector(".discountcode-select .yhFree").innerText;
    console.log("yhFree: "+ yhFree)

    zongjia();
})

//行无忧
$(".service-name-intro").click(function(){
    $(".hide").show();
});
$(".btn_close").click(function(){
    $(".hide").hide();
});
$(".butn").click(function(){
    $(".hide").hide();
});

//发票信息
$(".need-invoice").click(function(){
    var mark = document.querySelector(".need-invoice");
    if(mark.checked){
        $(".invoice-info").show();
    }else{
        $(".invoice-info").hide();
    }
})

//添加备注
$(".need-remark").click(function(){
    var mark = document.querySelector(".need-remark");
    if(mark.checked){
        $(".remark-info").show();
    }else{
        $(".remark-info").hide();
    }
})

//服务单选
function checkedThis(obj){
    var boxArray = document.getElementsByName('fwName');
    for(var i=0;i<boxArray.length;i++){
        if(boxArray[i]==obj && obj.checked){
            boxArray[i].checked = true;
        }else{
            boxArray[i].checked = false;
        }
    }
 }

 //费用明细
 var tru = true;
 $(".i1,.i2").click(function(){
    if (tru){
        $(".price-drop-open").hide();
        $(".price-drop-close").show();
        $("#baseRateDetail").show();
        tru = false;
    }else{
        $(".price-drop-open").show();
        $(".price-drop-close").hide();
        $("#baseRateDetail").hide();
        tru = true;
    }
 })

 $(".i3,.i4").click(function(){
    if (tru){
        $(".price-drop-open").hide();
        $(".price-drop-close").show();
        $("#serviceList").show();
        tru = false;
    }else{
        $(".price-drop-open").show();
        $(".price-drop-close").hide();
        $("#serviceList").hide();
        tru = true;
    }
 })


 
 var addFwName = null;
 var addFwCost = 0;

 //总价
 function zongjia(){
    var totalPrice = 430;

    var allCheckBox = document.querySelectorAll(".fw");
    for(var i = 0;i<allCheckBox.length;i++){
        var checkBox = allCheckBox[i];
        // console.log(checkBox)
        if(checkBox.checked){
            addFwName = checkBox.getAttribute("data-ba-action");
            addFwCost = checkBox.parentElement.parentElement.lastElementChild.firstElementChild.nextElementSibling.innerText;
            console.log("addFwCost:"+addFwCost)
        }
    }

    totalPrice = totalPrice + parseInt(addFwCost) - parseInt(yhFree);

    document.querySelector(".sum_price").innerText = totalPrice;
    console.log("addFwName: "+ addFwName)
    console.log("totalPrice: "+totalPrice)
 }

 zongjia();

 //服务增加
 $(".fw").click(function(){
    zongjia();
 })